<template>
    <div class="back_contain_n ParamSet">
        <div class="leftList">
            <li v-for="(item,index) in paramList" :key="index" :class="{'active': viewType == item.index}" @click="changeView(item,item.index)">{{item.name}}</li>
        </div>
        <div class="mainTable">
            <material-type v-if="viewType == 0" ref="base1"></material-type>
            <in-out v-if="viewType == 1" ref="base1"></in-out>
            <dw v-if="viewType == 2" ref="base1"></dw>
            <machineType v-if="viewType == 3" ref="base1"></machineType>
            <meter-info v-if="viewType == 4" ref="base1"></meter-info>
			<message-person v-if="viewType == 6" ref="base1"></message-person>
        </div>

		<el-dialog title="验证密码" :visible.sync="codeDialog" width="30%" class="zll-dialog">
			<div class="zll-form">
				<el-form :model="codeForm" class="demo-ruleForm">
					<el-form-item prop="password" label="密码：">
						<el-input type="password" v-model="codeForm.password" autocomplete="off" show-password
								  placeholder="请输入密码" class="input_right">
						</el-input>
					</el-form-item>
				</el-form>
				<div class="dialog-footer">
					<p class="zll-botton Info" @click="codeDialog = false">关 闭</p>
					<p class="zll-botton" @click="valiadatorPwd">提 交</p>
				</div>
			</div>
		</el-dialog>
    </div>
</template>

<script>
import materialType from './material-type/index.vue';
import inOut from './in-out/index.vue';
import Dw from './dw/index.vue';
import machineType from './machine-type/index.vue';
import meterInfo from './meter/index.vue';
import messagePerson from './message-person/index.vue';
import {getStore} from "@/plugins/localStore";
export default {
    data() {
        return {
            viewType: 0,
            paramList: [
                { name: "物料品类",index:0},
                { name: "出入库类型",index:1},
                { name: "计量单位",index:2},
                { name: "挤塑机号",index:3},
                { name: "电表",index:4},
				{ name: "短信接收人",index:6},
            ],
            addDialog: false,

			codeForm: {
				id:'',
				password: '',
			},
			codeDialog: false,
			opType:'',
        };
    },
    methods: {
        changeView(val,index){
            this.viewType = index
        },

		openPwdDialog(opType){
			this.codeForm.password = '';
			this.opType = opType;
			this.$refs[this.opType].doAction();
		},

		valiadatorPwd(){
			let self = this;
			self.codeForm.id = getStore().id;
			return new Promise((resolve, reject) => {
				if(!self.codeForm.password){
					self.$message.error('请输入密码');
				}else{
					self.$http({
						url: "/jinl/login/getLoginDetail",
						method: "post",
						params:self.codeForm
					}).then(resp => {
						if (resp.success) {
							self.codeDialog = false;
							self.$refs[self.opType].doAction();
						}else{
							self.$message.error(resp.message);
						}
					});
				}
			});
		}

    },
    components: {
        materialType,inOut,Dw,machineType,meterInfo,messagePerson
    }
};
</script>

<style lang="scss" scoped>
.ParamSet {
    display: flex;
    height: 100%;
    .leftList {
        width: 110px;
        margin-right: 40px;
        margin-top: 105px;
        li {
            list-style: none;
            height: 30px;
            line-height: 30px;
            font-size: 12px;
            background: #dddddd;
            border: 1px solid #cccccc;
            color: #333;
            text-align: center;
            cursor: pointer;
            margin-bottom: 10px;
            transition: all .5s;
            &.active {
                background: #00D1D0;
                border: 1px solid #00D1D0;
                color: #fff;
                position: relative;
                &::after {
                    content: ' ';
                    width: 0;
                    height: 0;
                    border-top: 12px solid transparent;
                    border-left: 12px solid #00D1D0;
                    border-bottom: 12px solid transparent;
                    position: absolute;
                    right: -15px;
                    top: 1px;
                }
            }
        }
    }
    .mainTable {
        width: calc(100% - 150px);
    }

	.zll-form {
		padding: 20px 40px 20px 20px;
		.dialog-footer {
			display: flex;
			justify-content: space-evenly;
			margin-top: 15px;
			.zll-botton {
				margin: 0;
			}
		}
	}
}
</style>
